﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.constant;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;

namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("LoopIndexName", "LoopItemName")]
    public class ForEachNParam:BaseParam {
        private string listName = "";
        private string loopIndexName = "loopIndex";
        private string loopItemName = "loopItem";
        private string startIndex = "0";
        private string endIndex = "-1";

        public string ListName {
            get => listName; 
            set { 
                listName = value;
                NotifyPropertyChanged("ListName");
            }  
        }
        public string LoopIndexName {
            get => loopIndexName; 
            set { 
                loopIndexName = value;
                NotifyPropertyChanged("LoopIndexName");
            }
}
        public string LoopItemName {
            get => loopItemName; 
            set { 
                loopItemName = value;
                NotifyPropertyChanged("LoopItemName");
            }  
        }

        public string StartIndex {
            get => startIndex; 
            set { 
                startIndex = value;
                NotifyPropertyChanged("StartIndex");
            }  
        }

        public string EndIndex {
            get => endIndex; 
            set { 
                endIndex = value;
                NotifyPropertyChanged("EndIndex");
            }  
        }

        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.loopIndexName = this.GetLatestName(this.loopIndexName, globleData);
            this.loopItemName = this.GetLatestName(this.loopItemName, globleData);
        }
    }
}
